import { userAccountLogin } from '@/api/user.js'
// 用户信息管理模块
export default {
  namespaced: true,
  state: () => ({
    // 个人用户信息
    profile: {
      id: '',
      nickname: '',
      avatar: '',
      token: '',
      mobile: ''
    }
  }),
  mutations: {
    setUser (state, userInfo) {
      state.profile = userInfo
    },
    // 清空信息
    deleteUserInfo (state) {
      state.profile = {}
    }
  },
  actions: {
    async getUserInfo (ctx, data) {
      const res = await userAccountLogin(data)
      ctx.commit('setUser', res.data.result)
    }
  },
  getters: {}
}
